#include"comm.h"
int main()
{
  if(mkfifo(FILE_NAME,0644)<0)
  {
    perror("mkfifo");
    return 1;
  }
  int fd=open(FILE_NAME,O_RDONLY);
  if(fd<0)
  {
    perror("open");
    return 2;
  }
  char s[100];
  printf("创建成功\n");
  while(1)
  {
    s[0]=0;//清空字符串
    ssize_t n=read(fd,s,sizeof(s)-1);
    if(n>0)
    {
     s[n]=0;
     printf("server receive:%s\n",s);
    }
    else if(n==0)
    {
      printf("read over\n");
      break;
    }
    else 
    {
      printf("read error\n");
    }
  }
  return 0;
}
